
<?php include("header.php"); ?>

<script type="text/javascript">

function addGroup() {
    window.location.href = "<?php echo APPLICATION_URL;?>/group/form/";
}

function allowAccess(id, value)
{
	if (value == '1') {
		value = '0';
	} else {
		value = '1';
	}
	var agr = new Array();
	agr.push(id);
	agr.push(value);
	if(callFunction('Group::allowAccess',agr) != '1')
	{
		alert('<?php echo _MSG_ALLOW_ACCESS_FAILED; ?>');
		return false;
	}

	if (value != '1') {
		document.getElementById("not_allow_access_"+id).style.display = "";
		document.getElementById("allow_access_"+id).style.display = "none";
        document.getElementById("lbl_not_allow_access_"+id).style.display = "";
		document.getElementById("lbl_allow_access_"+id).style.display = "none";
	} else {
		document.getElementById("not_allow_access_"+id).style.display = "none";
		document.getElementById("allow_access_"+id).style.display = "";
        document.getElementById("lbl_not_allow_access_"+id).style.display = "none";
		document.getElementById("lbl_allow_access_"+id).style.display = "";
	}
}
</script>
	<div class="one_third">
		<div class="box_tool">
			<div class="box_head"><?php echo _LB_TOOLBOX; ?></div>

			<div class="box_content">
                <a id="auto_GROUP_add" href="#" onclick="addGroup();">
					<?php echo _LB_ADD_GROUP; ?>
				</a>
			</div>
		</div>
		<div class="spacer"></div>
		<div class="box_tool">
			<div class="box_head"><?php echo _LB_SEARCH; ?></div>
			<div class="box_content" id="filter_panel">
				<table>
				<form name='form_filter' method="post" action="">
				<tr>
					<td width="40%"><?php echo _LB_GROUP_NAME; ?></td>
					<td width="60%">
						<input type="text" name="name" id="name" value="<?php echo $filter['name']; ?>" style="width: 180px;"/>
					</td>
				</tr>
                <tr>
					<td class="submit" colspan="2" style="padding-top:10px;">
						<a id="auto_group_search" class="tribullet" style="float:right" id="obj_search" href="#" onclick="document.form_filter.submit();"><?php echo _LB_FIND;?></a>
					</td>
				</tr>
				</form>
				</table>
			</div>
		</div>
	</div>

	<div class="two_third" style="height:1%">
		<div class="box_two_third">
			<div class="box_head"><?php echo _LB_GROUP; ?></div>
			<div class="box_content">
			<?php if($group->countRows()) { ?>
					<?php while($group->fetchNext()) { ?>
					<div class="object" robotid="<?php echo $group->id; ?>">
						<div class="head">
							<div class="right remove_top">
                                <?php if ($group->id != ADMIN) {?>
                                <span id="not_allow_access_<?php echo $group->id;?>" <?php if ($group->allow_access == '0') { ?>style="display: none;"<?php } ?>>
                                    <a id="auto_group_not_allow_access_<?php echo $group->id;?>" href="#allow_access<?php echo $group->id;?>" onclick="javascript:allowAccess(<?php echo $group->id;?>, '0');">
                                        <img src="<?php echo IMG_URL; ?><?php echo IMAGE_DISABLED_SMALL;?>" title="<?php echo _LB_ALLOW_ACCESS_NO;?>" alt="<?php echo _LB_ALLOW_ACCESS_NO;?>"/>
                                    </a>
                                </span>
                                <span id="allow_access_<?php echo $group->id;?>" <?php if ($group->allow_access == '1') { ?>style="display: none;"<?php } ?>>
                                    <a id="auto_group_allow_access<?php echo $group->id;?>" href="#not_allow_access_<?php echo $group->id;?>" onclick="javascript:allowAccess(<?php echo $group->id;?>, '1');">
                                        <img src="<?php echo IMG_URL; ?><?php echo IMAGE_ENABLED_SMALL;?>" title="<?php echo _LB_ALLOW_ACCESS_YES;?>" alt="<?php echo _LB_ALLOW_ACCESS_YES;?>"/>
                                    </a>
                                </span>
                                <?php } ?>
								<a id="auto_group_edit_<?php echo $group->id;?>" href="<?php echo APPLICATION_URL;?>/group/form/<?php echo $group->id;?>">
									<img src="<?php echo IMG_URL;?><?php echo IMAGE_NAME_EDIT_SMALL;?>" title="<?php echo _LB_EDIT;?>" alt="<?php echo _LB_EDIT;?>"/>
								</a>
								<?php if($group->id != ADMIN) {?>
									<a id="auto_group_delete_<?php echo $group->id;?>" onclick="return confirm('<?php echo _MSG_GROUP_DELETE_CONFIRM;?>');" href="<?php echo APPLICATION_URL;?>/group/delete/<?php echo $group->id;?>">
										<img src="<?php echo IMG_URL;?><?php echo IMAGE_NAME_DELETE_SMALL?>" title="<?php echo _LB_DELETE;?>" alt="<?php echo _LB_DELETE;?>"/>
									</a>
							  	<?php } else { ?>
									<img class="small" src="<?php echo IMG_URL;?>delete_not_small.png"/>
								<?php } ?>
							</div>
							<b><?php echo $group->name;?></b>
						</div>
						<div class="content">
							<table border="0" cellpadding="3" cellspacing="0">
                                <tr>
									<td width="20%"><?php echo _LB_ALLOW_ACCESS;?>&nbsp;:&nbsp;</td>
									<td>
										<span id="lbl_not_allow_access_<?php echo $group->id;?>" <?php if ($group->allow_access == '0') { ?>style="display: none;"<?php } ?>>
                                            <?php echo _LB_YES;?>
                                        </span>
                                        <span id="lbl_allow_access_<?php echo $group->id;?>" <?php if ($group->allow_access == '1') { ?>style="display: none;"<?php } ?>>
                                            <?php echo _LB_NO;?>
                                        </span>
									</td>
								</tr>
								
							</table>
						</div>
					</div>
					<?php } ?>
			<?php } else { ?>
				<p><?php echo _MSG_NO_EXISTING_GROUP;?></p>
			<?php } ?>
			</div>
		</div>
		
	</div>
<?php include("footer.php"); ?>
